﻿$(document).ready(function () {

    btn_sidebarmenu_gift_search();
    btn_sidebarmenu_gift_add();

    btn_sidebarmenu_user_search();
    btn_sidebarmenu_user_add();

    btn_sidebarmenu_datarecord_gift();
    btn_sidebarmenu_datarecord_user();

    btn_logo();
    btn_logoff();

    btn_content_gift_add();
    btn_content_user_add();
});

function btn_sidebarmenu_gift_search() {
    $("#btn_sidebarmenu_gift_search").click(function (event) {

        var reg = new RegExp("(^|&)" + "username" + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        var username = null;
        if (r != null)
            username = unescape(r[2]);

            window.location.href = "/Gift/Gift_Search?username=" + username;
    });
}

function btn_sidebarmenu_gift_add() {
    $("#btn_sidebarmenu_gift_add").click(function (event) {

        var reg = new RegExp("(^|&)" + "username" + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        var username = null;
        if (r != null)
            username = unescape(r[2]);

        window.location.href = "/Gift/Gift_Add?username=" + username;
    });
}

function btn_sidebarmenu_user_search() {
    $("#btn_sidebarmenu_user_search").click(function (event) {

        var reg = new RegExp("(^|&)" + "username" + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        var username = null;
        if (r != null)
            username = unescape(r[2]);

        window.location.href = "/User/User_Search?username=" + username;
    });
}

function btn_sidebarmenu_user_add() {
    $("#btn_sidebarmenu_user_add").click(function (event) {

        var reg = new RegExp("(^|&)" + "username" + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        var username = null;
        if (r != null)
            username = unescape(r[2]);

        window.location.href = "/User/User_Add?username=" + username;
    });
}

function btn_sidebarmenu_datarecord_gift() {
    $("#btn_sidebarmenu_datarecord_gift").click(function (event) {

        var reg = new RegExp("(^|&)" + "username" + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        var username = null;
        if (r != null)
            username = unescape(r[2]);

        window.location.href = "/DataRecord/GiftRecord?username=" + username;
    });
}

function btn_sidebarmenu_datarecord_user() {
    $("#btn_sidebarmenu_datarecord_user").click(function (event) {

        var reg = new RegExp("(^|&)" + "username" + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        var username = null;
        if (r != null)
            username = unescape(r[2]);

        window.location.href = "/DataRecord/GiftRecord?username=" + username;
    });
}

function btn_logo() {
    $(".btn_logo").die().live("click", function (e) {
        e.preventDefault();

        var reg = new RegExp("(^|&)" + "username" + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        var username = null;
        if (r != null)
            username = unescape(r[2]);

        window.location.href = "/Home/Index?username=" + username;
    });
}

function btn_logoff() {
    $("#btn_logoff").die().live("click", function (e) {
        e.preventDefault();
        window.location.href = "/Login/Login";
    });
}

function btn_content_gift_add() {
    $("#btn_content_gift_add").click(function (event) {

        var reg = new RegExp("(^|&)" + "username" + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        var username = null;
        if (r != null)
            username = unescape(r[2]);

        window.location.href = "/Gift/Gift_Add?username=" + username;
    });
}

function btn_content_user_add() {
    $("#btn_content_user_add").click(function (event) {

        var reg = new RegExp("(^|&)" + "username" + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        var username = null;
        if (r != null)
            username = unescape(r[2]);

        window.location.href = "/User/User_Add?username=" + username;
    });
}